<?php
/**
 * 栏目验证规则
 * Created by Sublime Text 3.
 * @authors Rejeo (rejeo@qq.com)
 * @date    2018-04-20 16:54:38
 * @version $Id$
 */
namespace app\admin\validate;
use think\Validate;
// 验证规则配置
class Category extends Validate
{
    /*验证规则，注意多去使用一些内置规则*/
    protected $rule = [
        'id'        => 'number',
        'parent_id' => 'number',
        'name'      => 'require|max:30|unique:category',
        'status'    => 'number|in:-1,0,1',
        'listorder' => 'number',
    ];
    /*验证提示*/
    protected $message = [
        'parent_id.number' => '分类父栏目id必须是数字',
        'id.number' => '分类id必须是数字',
        'status.number' => '分类状态必须是数字',
        'status.in' => '分类状态范围不合法',
        'name.require' => '分类名必须填写！',
        'name.unique' => '栏目已存在！',
        'listorder.number' => '排序规则必须是数字',
        // 'title.unique' => '友链已存在！',

    ];
    /*场景验证*/
    /*如验证add场景（该场景定义只需要验证name和parent_id字段）*/
    protected $scene = [
        'add' => ['parent_id','name','id'],
        'status' => ['id','status'],
        // 'links' => ['title'=>'require|max:30|unique:links','url','desc'],
    ];
}
